<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText value="Gestione Menu (passo 3)" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="menu" />
	</ui:define>
	<ui:define name="content">
		<h:form>
			<center>
				<p:panel header="Gestione Menu (passo 3)">

					<h:panelGrid columns="2" style="width: 95%"
						columnClasses="col1,col2">

						<h:outputLabel value="Nome:" for="nome" />
						<h:outputText id="nome" value="#{menuController.element.name}"
							style="width: 100%;" />

						<h:outputLabel value="Descrizione:" for="descrizione" />
						<h:outputText id="descrizione"
							value="#{menuController.element.description}"
							style="width: 100%;" />

						<h:outputLabel value="Percorso:" for="percorso" />
						<h:outputText id="percorso"
							value="#{menuController.element.path}" style="width: 100%;" />

					</h:panelGrid>
					<br />

					<b> <h:outputText
							value="NB: eventuali modifiche al percorso proposto in automatico dal sistema devono rispettare la forma" />
						<br /> - <i>/page/xyz/id-pagina</i> nel caso di percorsi non
						assoluti<br /> - <i>http://xyz'</i> nel caso di percorsi relativi<br />
					</b>
					<br />

					<p:dataTable var="menuItem" value="#{menuController.menuItemModel}">

						<p:column rendered="#{not menuController.element.dynamic}">
							<f:facet name="header">
								<h:outputText value="ordinamento" />
							</f:facet>
							<h:inputText value="#{menuItem.sortOrder}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="nome" />
							</f:facet>
							<h:inputText value="#{menuItem.name}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="descrizione" />
							</f:facet>
							<h:inputText value="#{menuItem.description}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="percorso" />
							</f:facet>
							<h:inputText value="#{menuItem.path}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="assoluto" />
							</f:facet>
							<h:selectBooleanCheckbox value="#{menuItem.absolute}" />
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="operazioni" />
							</f:facet>
							<h:commandLink
								action="#{menuController.rimuoviItem(menuItem.id)}"
								value="rimuovi" rendered="#{not empty menuItem.id}" />
						</p:column>

					</p:dataTable>

				</p:panel>
				<br /> <br />

				<h:panelGrid columns="4">
					<h:commandButton action="#{menuController.save}" value="Salva"
						rendered="#{empty menuController.element.id}" />

					<h:commandButton action="#{menuController.update}"
						value="Salva le modifiche"
						rendered="#{not empty menuController.element.id}" />

					<h:commandButton id="reset" action="#{menuController.reset}"
						value="Annulla" immediate="true" />
				</h:panelGrid>
			</center>

		</h:form>
	</ui:define>
</ui:composition>